package cs575.wido.ui;

import cs575.client.GroupEx;
import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;

import cs575.client.Task;
import cs575.wido.action.GroupTaskAction;
import cs575.wido.action.RemoveGroupMemberAction;
import cs575.wido.model.MemberListModel;

import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTabbedPane;
import javax.swing.JList;

public class GroupDetailsWindow extends JDialog {
	private Task task;
	private cs575.client.GroupEx group;
	private GroupDetailsPane detailsPane;
	private GroupMemberViewer memberViewer;
	
	/**
	 * Launch the application.
	 * 
	public static void main(String[] args) {
		try {
			GroupDetailsWindow dialog = new GroupDetailsWindow(null);
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	*/

	public GroupDetailsWindow() {
		this(new Task());
	}
	
	public GroupDetailsWindow(Task task) {
		this.task = task;
		setTitle("Group Details");
		setBounds(100, 100, 450, 300);
		getContentPane().setLayout(new BorderLayout());
		
		JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
		getContentPane().add(tabbedPane, BorderLayout.CENTER);
		
		tabbedPane.addTab("Group Details", null, buildGroupDetailTab(), null);
		tabbedPane.addTab("Group Members", null, buildGroupMemberTab(), null);
		
		pack();
	}
	
	private JComponent buildGroupDetailTab() {
		detailsPane = new GroupDetailsPane(this);
		return detailsPane;
	}

	private JComponent buildGroupMemberTab() {
		this.memberViewer = new GroupMemberViewer();
		return this.memberViewer;
	}

	public GroupEx getGroup() {
		return group;
	}

	public void setGroup(GroupEx group) {
		this.group = group;
		detailsPane.setGroup(group);
		memberViewer.setGroup(group);
	}
        
        public void setGroup(String[] group) {
		detailsPane.setGroup(group);
		//memberViewer.setGroup(group);
	}
}
